package com.ruoyi.develop.goodsSaleChuan.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.develop.goodsSaleChuan.domain.GoodsSaleChuan;
import com.ruoyi.develop.goodsSaleChuan.service.IGoodsSaleChuanService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 串行金具Controller
 * @author lmm
 * @date 2025-07-05
 */
@RestController
@RequestMapping("/goodsSaleChuan/goodsSaleChuan")
public class GoodsSaleChuanController extends BaseController {
    @Autowired
    private IGoodsSaleChuanService goodsSaleChuanService;

    /**
     * 查询串行金具列表
     */
    @PreAuthorize("@ss.hasPermi('develop:GoodsSaleChuan:query')")
    @GetMapping("/list")
    public TableDataInfo list(GoodsSaleChuan entity) {
        startPage();
        List<GoodsSaleChuan> list = goodsSaleChuanService.selectList(entity);
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('develop:GoodsSaleChuan:query')")
    @GetMapping("/selectListGroupByModels")
    public TableDataInfo selectListGroupByModels(GoodsSaleChuan entity) {
        startPage();
        List<GoodsSaleChuan> list = goodsSaleChuanService.selectListGroupByModels(entity);
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('develop:GoodsSaleChuan:query')")
    @GetMapping("/selectByModels")
    public TableDataInfo selectByModels(GoodsSaleChuan entity) {
        startPage();
        List<GoodsSaleChuan> list = goodsSaleChuanService.selectByModels(entity);
        return getDataTable(list);
    }


    @PreAuthorize("@ss.hasPermi('develop:GoodsSaleChuan:query')")
    @GetMapping("/selectByGoodsSaleId")
    public TableDataInfo selectByGoodsSaleId(GoodsSaleChuan entity) {
        startPage();
        List<GoodsSaleChuan> list = goodsSaleChuanService.selectByGoodsSaleId(entity);
        return getDataTable(list);
    }
    /**
     * 导出串行金具列表
     */
    @PreAuthorize("@ss.hasPermi('develop:GoodsSaleChuan:export')")
    @Log(title = "串行金具", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GoodsSaleChuan entity) {
        List<GoodsSaleChuan> list = goodsSaleChuanService.selectList(entity);
        ExcelUtil<GoodsSaleChuan> util = new ExcelUtil<GoodsSaleChuan>(GoodsSaleChuan. class);
        util.exportExcel(response, list, "串行金具数据");
    }

    /**
     * 获取串行金具详细信息
     */
    @PreAuthorize("@ss.hasPermi('develop:GoodsSaleChuan:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return AjaxResult.success(goodsSaleChuanService.selectById(id));
    }

    /**
     * 新增串行金具
     */
    @PreAuthorize("@ss.hasPermi('develop:GoodsSaleChuan:add')")
    @Log(title = "串行金具", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody GoodsSaleChuan entity) {
        return toAjax(goodsSaleChuanService.insert(entity));
    }

    /**
     * 修改串行金具
     */
    @PreAuthorize("@ss.hasPermi('develop:GoodsSaleChuan:edit')")
    @Log(title = "串行金具", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody GoodsSaleChuan entity) {
        return toAjax(goodsSaleChuanService.update(entity));
    }

    /**
     * 删除串行金具
     */
    @PreAuthorize("@ss.hasPermi('develop:GoodsSaleChuan:remove')")
    @Log(title = "串行金具", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(goodsSaleChuanService.deleteByIds(ids));
    }
}
